Skip to content

Feature: AbstractRefractiveIndex, ConstantRefractiveIndex - #213

Merged
StackEnjoyer merged 4 commits into
masterfrom
feature/constant-refractive-index
Nov 2, 2026
Merged

StackEnjoyer merged 4 commits into
masterfrom
feature/constant-refractive-index

Conversation

@StackEnjoyer

@StackEnjoyer StackEnjoyer commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Features

  • Breaking: n must be an AbstractRefractiveIndex; numbers and functions throw a MethodError
  • ConstantRefractiveIndex: exported index without dispersion, replaces λ -> 1.5
  • BeamletOptics.AbstractRefractiveIndex: public contract n(λ) -> Real for own dispersion models
lens = SphericalLens(50mm, -50mm, 5mm, inch, ConstantRefractiveIndex(1.5))

struct Cauchy <: BeamletOptics.AbstractRefractiveIndex
    A::Float64
    B::Float64
end
(c::Cauchy)(λ) = c.A + c.B / (λ * 1e6)^2

Doc changes

  • Lens page and README pitch use ConstantRefractiveIndex; catalog links follow the new signatures
  • Agent skill: SKILL.md, CHECKLIST.md, API.md, components/{materials,lenses,beamsplitters,prisms-and-dummies}.md, templates 02, 03, 07

Internal changes

Closes #184

…184)

Every constructor that takes a refractive index accepts a plain number and
stores it as ConstantRefractiveIndex instead of a closure. Numbers are
normalized once in Lens(shape, n::Real) and Prism(shape, n::Real); the
factories pass n on, and the 8 per-constructor number methods are removed.
The agent skill now states that numbers are constant indices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StackEnjoyer StackEnjoyer added this to the v0.14.0 milestone Nov 2, 2026
@StackEnjoyer StackEnjoyer added the enhancement New feature or request label Nov 2, 2026
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.21%. Comparing base (0e7c3fb) to head (0a0f9b9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #213      +/-   ##
==========================================
+ Coverage   91.90%   92.21%   +0.31%     
==========================================
  Files          86       85       -1     
  Lines        4448     4421      -27     
==========================================
- Hits         4088     4077      -11     
+ Misses        360      344      -16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StackEnjoyer

Copy link
Copy Markdown
Owner Author

Agent review, round 1: approve with changes · 0 blocker, 2 should, 4 nit · merges cleanly, 4265 tests pass

  • Nine links on the docs component catalog no longer point at their reference entries
  • Numbers as n for cylindrical and flat-surface Lens constructors have no test
Full review for agents (7 findings)

Scope

Verified

  • Julia 1.13.0, each with julia --project=test <file>, 10 modules, 4265/4265 pass:
    test/TestUtils.jl 176, test/Components/TestBeamsplitters.jl 67, test/Components/TestPolarizers.jl 215,
    test/Lenses/TestSphericalLenses.jl 275, test/TestAgentSkill.jl 19, test/TestProperties.jl 197,
    test/Components/TestPrisms.jl 3201, test/Lenses/TestCylindricalLenses.jl 7,
    test/Lenses/TestAsphericalLenses.jl 33, test/TestAutoDiff.jl 75
  • Ad-hoc script at head:
    • Test.detect_ambiguities(BeamletOptics; recursive = true): 0
    • 23 constructor calls with n = 1.5, covering every method whose n the PR loosened: all construct. For the 19 single-index objects, properties reports "Index model" => "ConstantRefractiveIndex". The 4 doublets and triplets do not report it; the PR's tests cover DoubletLens and TripletLens, SphericalDoubletLens and SphericalTripletLens were only constructed
    • The docstring signatures in Base.Docs.meta match every changed ::Any @docs block; no @docs block names RefractiveIndex any more
    • repr(ConstantRefractiveIndex(1.5)) is ConstantRefractiveIndex{Float64}(1.5), valid code
    • A string, a complex number or nothing as n still throw MethodError, now from the Lens or Prism shape constructor
  • Checked by reading:
    • No n::RefractiveIndex argument is left in a function signature in src/ (struct bounds only) and no ::Function index argument, so the claim "every constructor" holds
    • All eight removed λ -> n methods are covered by Lens(shape, n::Real) and Prism(shape, n::Real)
    • _index_model falls back to the type name, so properties needs no new method
    • refractive_index(object, λ) still converts the result, so a Float32 index or a Dual wavelength behaves as with the closure
    • No name clash with OpticsBase
  • Not run: the full suite, the docs build, the BeamletOpticsGUI tests against this branch, the GLMakie template. CI status was not visible (the REST API was rate-limited and gh is not installed)

Findings

F1 · should · docs/src/components/catalog.json:132: nine catalog links use the old constructor signature

  • Finding: The hrefs at lines 132, 174, 181, 188, 209, 216, 223, 230 and 265 (ThinLens, RightAnglePrism, EquilateralPrism, DovePrism, RectangularPlateBeamsplitter, RoundPlateBeamsplitter, CubeBeamsplitter, RectangularCompensatorPlate, RoundLinearPolarizer) still end in Union{Function, DiscreteRefractiveIndex, SellmeierEquation}. That anchor no longer exists after this PR.
  • Evidence: Documenter derives the anchor from the docstring signature: a local build of an older master has BeamletOptics.CubeBeamsplitter-Tuple{Real, Union{Function, DiscreteRefractiveIndex, SellmeierEquation}} in reference.html. At head, Base.Docs.meta gives Tuple{Real, Any} for that entry, and the corresponding Any form for the other eight. catalog.json is hand-maintained (the showcase script writes no hrefs) and ComponentCatalog.vue:75 uses the href as it is, so no build step reports this. Unverified: the docs were not rebuilt, so the effect in the browser (the page opens without jumping to the entry) is inferred.
  • Expected: Each catalog link lands on the reference entry of its constructor.
  • Suggestion: The new anchors are the signatures printed by Docs.meta, e.g. Tuple{Real,%20Real,%20Real,%20Any} for ThinLens; Any replaces the Union{...} in the where form of RectangularCompensatorPlate.

F2 · should · test/Lenses/TestSphericalLenses.jl:79: new number paths of Lens are not tested

  • Finding: The PR loosens Lens methods for cylindrical surfaces (front and back, and front only), CircularFlatSurface and RectangularFlatSurface. These calls threw a MethodError for a number before, and no test calls them with one.
  • Evidence: The new testset covers SphericalLens, ThinLens, the rotationally symmetric Lens(surface, l, n), DoubletLens and TripletLens. test/Lenses/TestCylindricalLenses.jl has no number or ConstantRefractiveIndex case. All four calls work in my script, so this is a coverage gap, not a defect. AGENTS.md asks for tests with changed functionality.
  • Expected: A test fails if one of these methods stops accepting a number.

F3 · nit · test/TestProperties.jl:72: index model label of a number is not tested

  • Finding: A component built from a number used to report "function of λ" and now reports "ConstantRefractiveIndex". This visible change is not pinned by a test.
  • Evidence: test/TestProperties.jl checks only the closure and DiscreteRefractiveIndex labels; the new value was read from my script.
  • Expected: The label for a number is covered alongside the other two.

F4 · nit · src/OpticalComponents/Lenses.jl:175: docstring signatures still say n::RefractiveIndex

  • Finding: The signature lines of the two Lens docstrings at lines 175 and 325 keep n::RefractiveIndex, while the text below them says a number is accepted.
  • Evidence: Read at head. All other changed constructors have an untyped n in the code, and the docstrings of ThinLens and SphericalLens were updated.
  • Expected: The signature shown in the REPL agrees with what the method takes.

F5 · nit · skills/beamletoptics/API.md:10: skill examples keep closures for constant indices

  • Finding: components/materials.md now shows n_const = 1.5 as the constant index, but API.md:10, components/lenses.md:53 and :75, and templates 02, 03 and 07 still use λ -> 1.5. Template 02 calls it the "constant-index callable".
  • Evidence: git grep at head. The examples still run; the Notes of Docs: Agent skill forbids numbers as refractive index, constructors accept them #184 raised exactly this question, and the skill now gives two answers.
  • Expected: The skill shows one form for a constant index, since agents copy its examples.

F6 · nit · docs/src/basics/components/lenses.md:79: new paragraph splits the example from its figure

  • Finding: The paragraph on numbers sits between the LB1811 code block and ![Lens constructor](lens_constructor.png).
  • Evidence: Read at head, lines 60 to 81. Not rendered; that the figure belongs to the example is inferred from its position and name.
  • Expected: The figure follows the example it illustrates.

F7 · note · BeamletOpticsGUI: no breakage found, closures remain

  • Finding: The GUI still builds λ -> n for its "constant" glass and does not depend on the changed signatures. No change requested.
  • Evidence: Read in the local checkout at f77eabf, tests not run: src/LiveCatalog.jl:28 and :33 create the closure themselves, and the n isa Function check at test/TestLiveGlasses.jl:101 is on that closure, not on a BMO index. _glass_code(n) = repr(n) now gives valid code for a number-built lens.
  • Expected: No action for this PR. The GUI can move to numbers separately.

- Catalog links point at the new constructor signatures (F1)
- Tests for numbers in the cylindrical and flat-surface Lens methods (F2)
  and for the properties label of a number (F3)
- Lens docstring signatures show an untyped n (F4)
- Skill examples and templates use numbers for constant indices (F5)
- Number paragraph follows the LB1811 figure (F6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StackEnjoyer

Copy link
Copy Markdown
Owner Author

Agent response to review round 1 · 6 fixed, 1 noted · tests pass

Full response for agents

Findings

F1 · fixed in 5100dd4

The nine hrefs in docs/src/components/catalog.json now use the Any signatures, taken from Base.Docs.meta at this commit; no Union{Function, ...} anchor is left.

F2 · fixed in 5100dd4

New testset "Number as refractive index" in test/Lenses/TestCylindricalLenses.jl covers Lens(cyl, cyl, l, n), Lens(cyl, l, n) and Lens(rect, rect, l, n), including a back focal length check against the closure value. Lens(flat, flat, l, n) for CircularFlatSurface was added to the testset in test/Lenses/TestSphericalLenses.jl.

F3 · fixed in 5100dd4

test/TestProperties.jl checks "Index model" == "ConstantRefractiveIndex" and n(λ₀) for a lens built from a number.

F4 · fixed in 5100dd4

Both Lens docstring signatures show an untyped n.

F5 · fixed in 5100dd4

API.md, components/lenses.md (aspheric and doublet examples) and templates 02, 03 and 07 use numbers for constant indices. The "constant-index callable" comment in template 02 is gone.

F6 · fixed in 5100dd4

The paragraph on numbers comes after the LB1811 figure.

F7 · noted

The GUI keeps its closures for now. It can switch to numbers separately.

Verified

  • Julia 1.13.0, julia --project=test <file>: test/Lenses/TestSphericalLenses.jl 276/276, test/Lenses/TestCylindricalLenses.jl 11/11, test/TestProperties.jl 199/199, test/TestAgentSkill.jl 19/19
  • julia --project=docs skills/beamletoptics/scripts/run_templates.jl: 7/7 headless templates run
  • Round 0, before the review: full suite Pkg.test() passes (Aqua included) and detect_ambiguities reports 0
  • Not run: the docs build, template 07 with GLMakie (its only change is λ -> 1.5 → 1.5), the full suite after this commit

@StackEnjoyer

Copy link
Copy Markdown
Owner Author

Agent review, round 2: approve · 0 blocker, 0 should, 0 nit · merges cleanly, CI passes on Julia 1 and 1.12, docs build passes

Full review for agents (7 earlier findings resolved, 1 new note)

Scope

Verified

  • Julia 1.13.0, each with julia --project=test <file>, 4 modules, 505/505 pass:
    test/Lenses/TestCylindricalLenses.jl 11, test/Lenses/TestSphericalLenses.jl 276, test/TestProperties.jl 199, test/TestAgentSkill.jl 19 (runs the headless templates)
  • CI at 5100dd4, read from the GitHub check runs: Julia 1 success, Julia 1.12 success, Documentation success, codecov/patch and codecov/project success, Julia pre failure (see F8)
  • Ad-hoc script at head: all 40 hrefs of docs/src/components/catalog.json name a binding with a docstring and, where they carry a signature, equal a signature in Base.Docs.meta; no Union{Function is left
  • Checked by reading: the diff 73e7b23..5100dd4 changes only what F1 to F6 cover; n_glass in template 02 is only passed to constructors, never called; no constant-index closure is left in skills/
  • Not run: template 07 with GLMakie (its one change uses the same SphericalLens signature as templates 03 and API.md), the BeamletOpticsGUI tests against this branch, a local full suite (CI ran the test jobs above). The catalog links were not clicked in a browser; the Documentation job does not check them, the script above does

Findings

F1 · resolved

All nine hrefs use the Any signatures and match Base.Docs.meta.

F2 · resolved

test/Lenses/TestCylindricalLenses.jl and test/Lenses/TestSphericalLenses.jl now call all four methods with a number, and the cylindrical lens also has a back focal length check.

F3 · resolved

test/TestProperties.jl pins the label and n(λ₀) for a lens built from a number.

F4 · resolved

Both Lens docstring signatures show an untyped n.

F5 · resolved

API.md, components/lenses.md and templates 02, 03 and 07 use numbers.

F6 · resolved

The paragraph follows the figure.

F7 · resolved

Note from round 1, no change was requested.

F8 · note · .github/workflows/CI.yml:21: Julia pre fails, also on master

  • Finding: Julia pre fails at this head. This does not come from the PR as far as can be seen, and no change to the PR is requested. It was not visible in round 1 and the response does not mention it.
  • Evidence: The failure step ends at a similar point at 5100dd4 (log line 874, 11 min) and on master at 0e7c3fb (log line 882, 10.5 min) and eaab83e (log line 879, 6.5 min). The job failed on the last six master commits, and continue-on-error is set for pre in CI.yml. Unverified: the job logs need a login, so the cause was not read, and no prerelease Julia is installed here to reproduce it. The run at 73e7b23 failed later (log line 1184, 18.5 min), for a reason not read either.
  • Expected: No action for this PR. The failure on master is a separate matter.

Refractive indices are subtypes of AbstractRefractiveIndex, whose docstring
is the contract n(λ) -> Real; ConstantRefractiveIndex, DiscreteRefractiveIndex
and SellmeierEquation subtype it. Constructors take n::AbstractRefractiveIndex:
numbers and functions throw a MethodError, a constant index is
ConstantRefractiveIndex(c). The RefractiveIndex union, the number methods of
Lens/Prism and test_refractive_index_function are removed; a testset checks
the contract for every subtype in the package.

Breaking: λ -> 1.5 and 1.5 as n no longer work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StackEnjoyer StackEnjoyer changed the title Feature: ConstantRefractiveIndex, numbers as n everywhere Feature: AbstractRefractiveIndex, ConstantRefractiveIndex Nov 2, 2026
@StackEnjoyer

Copy link
Copy Markdown
Owner Author

Agent review, round 3: changes requested · 1 blocker, 2 should, 2 nit · merges cleanly, 4531 tests pass, Documentation CI fails

  • The docs build fails: an aspherical lens example still passes a function as n
  • Merging this alone breaks the constant glass of the GUI; GUI PR Bump codecov/codecov-action from 6 to 7 #56 has to land with it
  • Example pages still present anonymous functions as refractive indices, which now throw
Full review for agents (F8 still open, 6 new findings)

Scope

Verified

  • Julia 1.13.0, each with julia --project=test <file>, 13 modules, 4531/4531 pass:
    test/TestUtils.jl 178, test/Lenses/TestSphericalLenses.jl 275, test/Lenses/TestCylindricalLenses.jl 12,
    test/Lenses/TestAsphericalLenses.jl 33, test/Lenses/TestSurfaces.jl 132, test/Components/TestPrisms.jl 3201,
    test/Components/TestBeamsplitters.jl 66, test/Components/TestPolarizers.jl 215, test/TestProperties.jl 197,
    test/TestAgentSkill.jl 19 (runs the headless templates), test/TestAutoDiff.jl 75, test/TestBugFixes.jl 94, test/TestOpticsBaseExt.jl 34
  • CI at e434f0e, read from the GitHub check runs: Julia 1 success, Julia 1.12 success, codecov/patch and codecov/project success, Documentation failure (see F9), Julia pre failure (see F8)
  • Ad-hoc script at head:
    • 22 constructor calls, each with ConstantRefractiveIndex(1.5), 1.5 and λ -> 1.5: 22 build, 22 MethodError, 22 MethodError, as the PR description says
    • The Cauchy example of the PR description constructs, traces (3 rays) and reports "Index model" => "Cauchy"
    • All 40 hrefs of docs/src/components/catalog.json equal a signature in Base.Docs.meta (F1 has not regressed)
  • Checked by reading:
    • The src/ refactor: all constructors are typed, the (n::AbstractRefractiveIndex)(λ) fallback matches the error(lazy"...") style of other interfaces, no RefractiveIndex or test_refractive_index_function is left in the repository
    • The skill files agree with the new behavior, as AGENTS.md asks
    • BeamletOpticsGUI PR Bump codecov/codecov-action from 6 to 7 #56 (feature/abstract-refractive-index at ae62672): a search finds no closure or number as n left in src, docs or test
  • Left alone: paper/paper.tex:154 and :157 use closures; the file is the proceedings submission of September and I treat it as a snapshot
  • Not run: a local docs build, the GUI tests with Bump codecov/codecov-action from 6 to 7 #56 against this branch, the GLMakie template 07, a local full suite (the CI test jobs above ran). Job logs need a login, so no CI failure cause was read

Findings

F8 · still open · .github/workflows/CI.yml:21: Julia pre fails, also on master

No change requested. At e434f0e it stops at log line 869 after 7.2 min, close to the earlier runs on master. Cause still not read.

F9 · blocker · docs/src/assets/lens_assets/aspherical_lens_showcase.jl:27: asphere example passes a function as n

  • Finding: The script calls Lens(..., 0.7e-3, n -> 1.580200), which throws a MethodError since this commit. The docs build runs it through docs/src/basics/components/lenses.md:6, and CI always renders. The same snippet is printed for readers at docs/src/basics/components/lenses.md:150, in a plain julia block that nothing runs.
  • Evidence: The call at head throws MethodError: no method matching Lens(::EvenAsphericalSurface{Float64}, ::Float64, ::var"#71#72"). Documentation passed at 5100dd4 and fails at e434f0e, and docs/make.jl:88 only tolerates :missing_docs. Unverified: the job log needs a login, so the link between this call and the failing job is inferred. A second failure could sit behind this one. A search found no other closure in docs/src.
  • Expected: The Documentation job passes and the printed example runs as shown.

F10 · should · BeamletOpticsGUI src/LiveCatalog.jl:28: this PR breaks GUI main unless GUI #56 lands with it

  • Finding: GUI main builds λ -> n for the "constant" glass of the catalog, and its tests pass numbers and closures to the constructors. GUI main tracks this repository's master, so it breaks when this PR merges. The PR description does not mention the dependency.
  • Evidence: Read at GUI main b01e9a9: src/LiveCatalog.jl:28, Project.toml:25 (rev = "master"), and e.g. test/TestLiveCardRows.jl:62 and :68. GUI PR Bump codecov/codecov-action from 6 to 7 #56 replaces these. It uses BMO.ConstantRefractiveIndex at load time, so by reading it cannot pass before this PR is on master. Unverified: the GUI tests were not run with either side.
  • Expected: The dependency on GUI Bump codecov/codecov-action from 6 to 7 #56 is stated, and GUI main is broken for as short a time as possible. By the point above, that means merging this PR first and Bump codecov/codecov-action from 6 to 7 #56 directly after it.

F11 · should · docs/src/examples/double_gauss.md:33: prose still describes anonymous functions as indices

  • Finding: The code examples were migrated but the text around them was not. double_gauss.md:33 says the indices above "are given as anonymous functions", directly under code that uses ConstantRefractiveIndex. docs/src/examples/lens_groups.md:101 lists an anonymous function as a way to specify an index. The docstring example at src/Properties.jl:32 shows "Index model" => "function of λ", a label the package no longer produces.
  • Evidence: Read at head; _index_model is removed and SphericalLens without n reports "ConstantRefractiveIndex". The Properties.jl line was already wrong at 73e7b23, and rounds 1 and 2 missed it. These are plain text, so neither CI nor the tests see them.
  • Expected: Text and docstring examples describe what the package accepts and prints after this PR.

F12 · nit · src/OpticalComponents/Lenses.jl:38: comment says n may be any function

  • Finding: The comment above refractive_index(object, λ) justifies the conversion with "since n may be any function".
  • Evidence: Read at head; n is now an AbstractRefractiveIndex.
  • Expected: The comment describes the current type.

F13 · nit · test/Components/TestBeamsplitters.jl:1: whole file flipped from LF to CRLF

  • Finding: The commit converts this one file to CRLF, so it shows 407 changed lines where 25 are real.
  • Evidence: Carriage returns go from 0 at 5100dd4 and on master to one per line at head; git diff --ignore-space-at-eol shows +12 -13. No other file of the commit changes its line endings.
  • Expected: The file keeps the line endings it has on master.

F14 · note · src/Utils/RefractiveIndexUtils.jl:25: the index contract is no longer checked at construction

  • Finding: With test_refractive_index_function gone, a defective own subtype is accepted by the constructor and fails on first use. No change requested, this follows from making the docstring the contract.
  • Evidence: Measured at head: a subtype without a functor constructs and fails during the trace with the clear message refractive index n(λ) not defined for NoCall. A subtype returning a complex number constructs and throws an InexactError from refractive_index(object, λ).
  • Expected: No action for this PR.

- Asphere example and its printed copy use ConstantRefractiveIndex (F9)
- Prose and the properties docstring describe constant indices (F11)
- Comment on the conversion of the index type (F12)
- TestBeamsplitters.jl back to LF line endings (F13)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StackEnjoyer

Copy link
Copy Markdown
Owner Author

Agent response to review round 3 · 5 fixed, 2 noted · tests pass, local docs build passes

Full response for agents

Scope

The redesign in e434f0e is a decision of the maintainer, taken after round 2: indices are subtypes of AbstractRefractiveIndex, whose docstring is the contract, and constructors take nothing else. The RefractiveIndex union, the number methods and test_refractive_index_function are removed on purpose. The PR description now says so.

Findings

F8 · noted

Not caused by this PR, as on master.

F9 · fixed in 0a0f9b9

docs/src/assets/lens_assets/aspherical_lens_showcase.jl:27 and the printed copy at docs/src/basics/components/lenses.md:150 use ConstantRefractiveIndex(1.580200). The migration missed this closure because a comment followed it. A search for closures followed by a comment, over src, test, docs/src and skills, finds nothing else.

F10 · fixed in the PR description

The description states the dependency: GUI #56 has to be merged directly after this PR, since GUI main tracks this repository's master. With #56 checked out, the full GUI suite passes against e434f0e, Aqua included; a temporary environment loaded this branch from a local path.

F11 · fixed in 0a0f9b9

double_gauss.md:33 and lens_groups.md:101 describe constant indices as ConstantRefractiveIndex, and the docstring example at src/Properties.jl:32 shows "Index model" => "ConstantRefractiveIndex".

F12 · fixed in 0a0f9b9

The comment says that a model n may return another number type.

F13 · fixed in 0a0f9b9

test/Components/TestBeamsplitters.jl is back to LF. A byte count over every file this branch changes finds no other flip of line endings, neither here nor in GUI #56.

F14 · noted

Accepted, as the review says.

Verified

  • Julia 1.13.0, julia --project=test <file>: test/Components/TestBeamsplitters.jl 66/66, test/TestProperties.jl 197/197
  • At e434f0e, before the review: full suite Pkg.test() passes, Aqua included; run_templates.jl 7/7
  • julia --project=docs docs/make.jl at 0a0f9b9: the Documenter stages pass, examples included; the only warning is the tolerated :missing_docs, and no name of this PR is in it. The Vitepress step did not run (no npm on this machine)
  • Not run: the full suite after 0a0f9b9 (only docs, a comment, a docstring example and line endings changed), template 07 with GLMakie, the merge with Bugfix: beamlets pass a Detector with stop = false #214

@StackEnjoyer
StackEnjoyer merged commit 051c316 into master Nov 2, 2026
6 of 7 checks passed
@StackEnjoyer
StackEnjoyer deleted the feature/constant-refractive-index branch November 2, 2026 23:20
StackEnjoyer pushed a commit that referenced this pull request Nov 7, 2026
* Test: coincident-boundary matrix for cemented lenses, beamsplitters and touching bodies (#167)

* Test: constant refractive indices as ConstantRefractiveIndex after #213

* Test: coincident boundaries read internals through one adapter, near-contact cases

- All access to BMO internals of TestCoincidentBoundaries.jl in one adapter block; the tests use
  exported names, AbstractTrees.children and the coating getter, no component or beamlet fields
- Beamlet split checked through the physical on-axis field for both models, with the documented
  Fresnel loss of the astigmatic beamlet at the uncoated back face of the plate
- Separate touching plates with gaps and overlaps far below and far above the coincidence
  tolerance, and rotated and moved together
- Benchmark adds the 50 lenses off the beam path (same code as #177)
- Leftover lines removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: thin splitter between plates checked ray by ray, no representation checks

- The branches of the thin beamsplitter between touching plates are compared with the reference
  trace in position, direction and index of every ray (ray_error, shared with path_error)
- Equal-glass doublet and triplet compared with the singlet by the sequence of media, not by the
  number of rays; the owner of a hit on coincident faces is no longer fixed
- Benchmark name column wide enough for the crowded rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: touching objects are one interface, stated as the target of the matrix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: touching plates carry the Fresnel loss of one glass-glass interface

- Polarized ray through touching plates at normal incidence: the flux n |E|² behind them is the
  Fresnel chain with one glass-glass step, none for equal glass; with a 1 µm gap two glass-air
  faces. @test_broken on master, passing with #178
- Fresnel transmission at normal incidence and the flux of a polarized ray as shared helpers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: uitt_hu <hugo.uittenbosch@dlr.de>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
StackEnjoyer added a commit that referenced this pull request Nov 8, 2026
* Test: coincident-boundary matrix for cemented lenses, beamsplitters and touching bodies (#167)

* Feature: coincident hits of touching surfaces, the hint only speeds up the trace (#167)

trace_all and trace_one collect all surfaces that a ray hits within
get_coincidence_tolerance() (1 nm) of the closest hit as a chain of
coincident hits. Objects whose bounding sphere lies beyond the closest hit
are not tested. The hinted object is tested first, but its hit no longer
wins over a closer one: among coincident hits, the hinted shape comes
first. Parts of doublets and cube beamsplitters that are moved apart now
show the air gap.

* Bugfix: coincident hits without a shape are kept (#177)

The shape of an Intersection is optional. Hits of objects with an own
intersect3d that leave it empty were taken for duplicates of each other,
such that only one of them stayed in the chain of coincident hits. Hits
without a shape are now always kept; duplicates no longer arise, since the
hinted object is not tested twice.

* Internal: hit chains with one default tolerance, first_of shared by the hint order

* Docs: core diagrams show coincident hits, the beyond-skip and the hint as an optimization

* Style: argument names and label comments (AGENTS.md N1, C1)

* Style: argument name in first_of_shape (N1)

* Test: constant refractive indices as ConstantRefractiveIndex after #213

* Test: constant refractive indices as ConstantRefractiveIndex after #213

* Test: coincident boundaries read internals through one adapter, near-contact cases

- All access to BMO internals of TestCoincidentBoundaries.jl in one adapter block; the tests use
  exported names, AbstractTrees.children and the coating getter, no component or beamlet fields
- Beamlet split checked through the physical on-axis field for both models, with the documented
  Fresnel loss of the astigmatic beamlet at the uncoated back face of the plate
- Separate touching plates with gaps and overlaps far below and far above the coincidence
  tolerance, and rotated and moved together
- Benchmark adds the 50 lenses off the beam path (same code as #177)
- Leftover lines removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: thin splitter between plates checked ray by ray, no representation checks

- The branches of the thin beamsplitter between touching plates are compared with the reference
  trace in position, direction and index of every ray (ray_error, shared with path_error)
- Equal-glass doublet and triplet compared with the singlet by the sequence of media, not by the
  number of rays; the owner of a hit on coincident faces is no longer fixed
- Benchmark name column wide enough for the crowded rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: touching objects are one interface, stated as the target of the matrix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test: touching plates carry the Fresnel loss of one glass-glass interface

- Polarized ray through touching plates at normal incidence: the flux n |E|² behind them is the
  Fresnel chain with one glass-glass step, none for equal glass; with a 1 µm gap two glass-air
  faces. @test_broken on master, passing with #178
- Fresnel transmission at normal incidence and the flux of a polarized ray as shared helpers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Bugfix: hinted objects in groups tested once, skip applies within groups (#177 review)

- closest_hits descends into object groups, so the hinted object is
  skipped there too and the members beyond the closest hit are not tested
- Contract: the bounding sphere of an object encloses every hit of its
  intersect3d, also of a method of its own; an object whose hits leave its
  shape returns NoBoundingSphere() (AbstractObject, bounding_sphere_of,
  AGENTS.md extension promise); tests for both object orders
- Hint and tracing_step! docstrings: the hint only orders the tests
- get_coincidence_tolerance: relation to the SDF surface threshold
- Style: isbeyond, is_in_chain (N1); typed skip and target (D1)
- Core diagram of trace_all shows closest_hits, skip and groups

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Bugfix: trace_all inferred again, skipped object boxed once, sphere tested once (#177 review r2)

- Type assertion on the recursive closest_hits call; @nospecialize skip, since an
  immutable hinted object was boxed again for every part
- Sphere pretest in the loop only once a hit is found; a group tests its sphere
  without a hit, an object leaves it to intersect3d
- Comments on groups describe the current path; core.md diagram updated
- Test: trace_all and trace_one inferred for System, grouped System and
  StaticSystem; allocations do not grow with the number of parts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Internal: group sphere test of closest_hits split into two statements, signatures reformatted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: core.md diagrams of the solver as plain yes/no flows, trace_all split into search and object hit, order of coincident hits stated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Feature: a system is an AbstractTrees tree, children(system) (#235)

* Internal: AbstractTrees.children(system) replaces _top_level (#234)

A System returns its objects and groups as built, other systems
objects(system). A System and an ObjectGroup print as one tree into the
given IO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Bugfix: render! of a system reads children(system), not the objects field (review r1 F1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: uitt_hu <hugo.uittenbosch@dlr.de>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: uitt_hu <hugo.uittenbosch@dlr.de>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: StackEnjoyer <93778924+StackEnjoyer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Agent skill forbids numbers as refractive index, constructors accept them

1 participant